﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditPrdTaskInfoForm.aspx.cs"
    Inherits="FX.CC.Andon.WebSite.BasicDataManage.EditPrdTaskInfoForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" method="post">
    <input name="TaskID" class="mini-hidden" />
    <div style="padding-left: 11px; padding-bottom: 5px;">
        <table style="table-layout: fixed;">
            <tr>
                <td style="width: 90px;" align="right">
                    产线：
                </td>
                <td style="width: 300px;">
                    <div id="LineID" name="LineID" class="mini-combobox" style="width: 300px;" popupwidth="300"
                        onvaluechanged="onLineIDChanged" required="true" textfield="LineName" valuefield="LineID"
                        url="../Service/BasicDataManageHandler.ashx?action=GetLineListByCombobox">
                        <div property="columns">
                            <div header="产线编号" field="LineCode">
                            </div>
                            <div header="产线名称" field="LineName">
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="width: 90px;" align="right">
                    日期：
                </td>
                <td style="width: 300px;">
                    <input name="BizDate" vtype="date:yyyy-MM-dd" style="width: 300px;" required="true"
                        class="mini-datepicker" />
                </td>
            </tr>
            <tr>
                <td style="width: 90px;" align="right">
                    班次：
                </td>
                <td style="width: 300px;">
                    <input name="ShiftID" class="mini-combobox" style="width: 300px;" textfield="ShiftName"
                        valuefield="ShiftID" url="../Service/BasicDataManageHandler.ashx?action=GetShiftListByCombobox"
                        required="true" />
                </td>
            </tr>
            <tr>
                <td style="width: 90px;" align="right">
                    产品：
                </td>
                <td style="width: 300px;">
                    <input name="PrdID" class="mini-buttonedit" allowinput="false" onbuttonclick="onPrdIdButtonEdit"
                        style="width: 300px;" required="true" />
                </td>
            </tr>
            <tr>
                <td style="width: 90px;" align="right">
                    设备：
                </td>
                <td style="width: 300px;">
                    <div id="EqID" name="EqID" class="mini-combobox" required="true" style="width: 300px;"
                        popupwidth="300" textfield="EqName" valuefield="EqID">
                        <div property="columns">
                            <div header="设备编号" field="EqCode" width="40%">
                            </div>
                            <div header="设备名称" field="EqName" width="60%">
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="width: 90px;" align="right">
                    生产序号：
                </td>
                <td style="width: 300px;">
                    <input name="ProcessIdx" class="mini-spinner" required="true" minvalue="0" maxvalue="999999999"
                        style="width: 300px;" />
                </td>
            </tr>
            <tr>
                <td style="width: 90px;" align="right">
                    计划数量：
                </td>
                <td style="width: 300px;">
                    <input name="PlanQty" class="mini-spinner" required="true" minvalue="0" maxvalue="999999999"
                        style="width: 300px;" />
                </td>
            </tr>
            <tr>
                <td style="width: 90px;" align="right">
                    计划时间：
                </td>
                <td style="width: 300px;">
                    <input name="PlanStartTime" class="mini-datepicker" required="true" format="yyyy-MM-dd H:mm:ss"
                        timeformat="H:mm:ss" showtime="true" style="width: 300px" />
                </td>
            </tr>
            <tr>
                <td style="width: 90px;" align="right">
                    实际时间：
                </td>
                <td style="width: 300px;">
                    <input name="PlanEndTime" class="mini-datepicker" required="true" format="yyyy-MM-dd H:mm:ss"
                        timeformat="H:mm:ss" showtime="true" style="width: 300px" />
                </td>
            </tr>
        </table>
    </div>
    <div style="text-align: center; padding: 10px;">
        <a class="mini-button" iconcls="icon-save" onclick="onOk" style="width: 60px; margin-right: 20px;">
            保存</a> <a class="mini-button" iconcls="icon-cancel" onclick="onCancel" style="width: 60px;">
                取消</a>
    </div>
    <script type="text/javascript">
        mini.parse();
        var form = new mini.Form("form1");
        var action;
        var FlowID;
        var EqID = mini.getbyName("EqID");
        function onLineIDChanged(e) {
            if (e.value) {
                EqID.setUrl("../Service/BasicDataManageHandler.ashx?action=GetEquipmentListByCombobox&LineID=" + e.value);
            }
        }
        function onPrdIdButtonEdit(e) {
            var btnEdit1 = e.sender;
            mini.open({
                url: "../CommForm/SelectProductForm.aspx",
                title: "选择产品",
                width: 650,
                height: 380,
                onload: function () {
                    //var iframe = this.getIFrameEl();
                    //iframe.contentWindow.SetData(null);
                },
                ondestroy: function (action) {
                    if (action == "ok") {
                        var iframe = this.getIFrameEl();
                        var data = iframe.contentWindow.GetData();
                        data = mini.clone(data);    //必须
                        mini.getbyName("PrdID").setValue(data.PrdID);
                        mini.getbyName("PrdID").setText(data.PrdName);
                    }
                }
            });
        }
        function onOk(e) {
            SaveData();
        }
        function CloseWindow(action) {
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function SetData(data) {
            if (data.action == "edit") {
                //跨页面传递的数据对象，克隆后才可以安全使用
                data = mini.clone(data);
                FlowID = data.FlowID;
                action = data.action;
                $.ajax({
                    url: "../service/BasicDataManageHandler.ashx?action=GetPrdTaskInfo&TaskID=" + data.TaskID,
                    cache: false,
                    success: function (text) {
                        var o = mini.decode(text);
                        form.setData(o);
                        form.setChanged(false);
                        EqID.setUrl("../Service/BasicDataManageHandler.ashx?action=GetEquipmentListByCombobox&LineID=" + o.LineID);
                        mini.getbyName("LineID").setValue(o.LineID);
                        mini.getbyName("LineID").setText(o.LineName);
                        mini.getbyName("ShiftID").setValue(o.ShiftID);
                        mini.getbyName("ShiftID").setText(o.ShiftName);
                        mini.getbyName("EqID").setValue(o.EqID);
                        mini.getbyName("EqID").setText(o.EqName);
                        mini.getbyName("PrdID").setValue(o.PrdID);
                        mini.getbyName("PrdID").setText(o.PrdName);
                    }
                });
            }
        }

        function SaveData() {
            var o = form.getData();
            o.FlowID = FlowID;
            var json = mini.encode([o]);
            form.validate();
            if (form.isValid() == false) return;
            if (action == "edit") {
                $.ajax({
                    url: "../Service/BasicDataManageHandler.ashx?action=ModifyPrdTask",
                    data: { data: json },
                    type: 'POST',
                    success: function (text) {
                        CloseWindow("save");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.responseText);
                    }
                });
            }
        }
        function GetData() {
            var o = form.getData();
            return o;
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
    </script>
    </form>
</body>
</html>
